//
//  YHYOwnercell.m
//  Home
//
//  Created by 杨泓晔 on 16/4/18.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "YHYDesignecell.h"

@interface YHYDesignecell ()
//@property(nonatomic,retain) UILabel *WXlabel;
@property (nonatomic, strong) UILabel *xmLabel;
@property (nonatomic, strong) UIImageView *headImageV;
@property (nonatomic, strong) UIImageView *NYimage;
@property (nonatomic, strong) UIImageView *NVYimage;
@property (nonatomic, strong)  UILabel *NVLabel;
@property (nonatomic, strong)  UILabel *NVLabel1;
@property (nonatomic, assign) BOOL isMen;


@end

@implementation YHYDesignecell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _isMen = YES;
        [self createSubView];
           }
    
    return self;
}
- (void)createSubView {
    //名字
    self.xmLabel = [[UILabel alloc]init];
    self.xmLabel.textColor = HS;
    self.xmLabel.font = [UIFont fontWithName:TFont size:TEXTCONTENTFONT2 * AUTO_WIDTH];

    [self.contentView addSubview:_xmLabel];
    [self.xmLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.left.mas_equalTo(15.00 * AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(6*18.00*AUTO_WIDTH, 25.00*AUTO_WIDTH));
    }];

    
    
}
- (void)setString:(NSString *)string {
    
    _string = string;
    self.xmLabel.text = _string;
}

- (void)setType:(NSInteger)type {
    
    if (_type != type) {
        _type = type;
        if (_type == 1) {
            [self createTypeOneView];
        } else if (_type == 2) {
            [self createheaderView];
        } else {
            [self createSexView];
        }
    }
}
- (void)setContent:(NSString *)content {
    
    _content = content;
    self.WXlabel.text = _content;
}

- (void)createTypeOneView {
    
    //绿色图片
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(310.00*AUTO_WIDTH, 15.00*AUTO_WIDTH, 40.00*AUTO_WIDTH, 40.00*AUTO_WIDTH)];
    imageView.image = [UIImage imageNamed:@"jiantou"];
    [self.contentView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.right.mas_equalTo(-21.00*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(18.00*AUTO_WIDTH, 18.00*AUTO_WIDTH));
        
    }];
    
    //选填
    self.WXlabel = [[UILabel alloc]initWithFrame:CGRectMake(100.00*AUTO_WIDTH, 23.00/AUTO_WIDTH, 100.00*AUTO_WIDTH, 10.00/AUTO_WIDTH)];
    self.WXlabel.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT2*TEXTWEIGHT];
    self.WXlabel.text = _content;
    self.WXlabel.textColor = HS;
    self.WXlabel.alpha=0.5;
    self.WXlabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.WXlabel];
    [self.WXlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(imageView.mas_left).offset(-6.00*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(200.00*AUTO_WIDTH, 18.00*AUTO_WIDTH));
        
    }];
}

- (void)createheaderView {
    
    //头像图片
    self.headImageV = [[UIImageView alloc]initWithFrame:CGRectMake(310.00*AUTO_WIDTH, 15.00*AUTO_WIDTH, 40.00*AUTO_WIDTH, 40.00*AUTO_WIDTH)];
    if (!_image) {
        
        self.headImageV.image = [UIImage imageNamed:@"touxiang"];
    } else {
        self.headImageV.image = _image;
    }
    self.headImageV.layer.cornerRadius = 20.00*AUTO_WIDTH;
    self.headImageV.layer.masksToBounds = YES;
//    self.headImageV.layer.borderColor = GH.CGColor;
//    self.headImageV.layer.borderWidth = 1;
    [self.contentView addSubview:self.headImageV];
    [self.headImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView.mas_right).offset(-37.00*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(41.00*AUTO_WIDTH, 41.00*AUTO_WIDTH));
    }];
}

- (void)createSexView {
    
    UIView *NVView = [[UIView alloc]initWithFrame:CGRectMake(175.00*AUTO_WIDTH, 00.00*AUTO_WIDTH, 200.00*AUTO_WIDTH, 98.00*AUTO_WIDTH/2)];
    [self.contentView addSubview:NVView];
    [NVView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView.mas_right).offset(-18.00*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(160.00*AUTO_WIDTH/2, 25.00*AUTO_WIDTH));
        
    }];
    //绿色图片
    self.NYimage = [[UIImageView alloc]initWithFrame:CGRectMake(80.00*AUTO_WIDTH, 39.00*AUTO_WIDTH/2, 10.00*AUTO_WIDTH, 10.00*AUTO_WIDTH)];
//    self.NYimage.backgroundColor = [UIColor greenColor];
    self.NYimage.layer.masksToBounds = YES;
    self.NYimage.layer.cornerRadius = 8.00/2;
    self.NYimage.layer.borderColor = [[UIColor colorWithRed:10/255.0 green:162/255.0 blue:233/255.0 alpha:1]CGColor];
    self.NYimage.backgroundColor=[UIColor colorWithRed:10/255.0 green:162/255.0 blue:233/255.0 alpha:1];
    self.NYimage.layer.borderWidth = 1.00;
    [NVView addSubview:_NYimage];
    [self.NYimage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(NVView).offset(18.00*AUTO_WIDTH/2);
        make.left.equalTo(NVView).offset(5.00*AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(8.00*AUTO_WIDTH, 8.00*AUTO_WIDTH));
        
    }];
    
    //男
    _NVLabel= [[UILabel alloc]initWithFrame:CGRectMake(self.NYimage.frame.origin.x +20.00*AUTO_WIDTH, 10.00*AUTO_WIDTH/2, 20.00*AUTO_WIDTH, 39.00*AUTO_WIDTH)];
    _NVLabel.text = @"男";
    _NVLabel.textColor =[UIColor colorWithRed:10/255.0 green:162/255.0 blue:233/255.0 alpha:1];
    _NVLabel.alpha=0.7;
    _NVLabel.textAlignment = NSTextAlignmentCenter;
    _NVLabel.font = [UIFont systemFontOfSize:TEXTLABELFONT*TEXTWEIGHT];
    [NVView addSubview:_NVLabel];
    [_NVLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(NVView).offset(7.00*AUTO_WIDTH/2);
        make.left.equalTo(self.NYimage.mas_right);
        make.right.equalTo(NVView.mas_centerX);
        
    }];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(womenAction:)];
    [self.NYimage addGestureRecognizer:tap];
    [_NVLabel addGestureRecognizer:tap];
    
    
    //红色图片
    self.NVYimage = [[UIImageView alloc]init];
    self.NVYimage.backgroundColor = [UIColor whiteColor];
    self.NVYimage.layer.masksToBounds = YES;
    self.NVYimage.layer.cornerRadius = 8.00/2;
    self.NVYimage.layer.borderColor = [UIColor grayColor].CGColor;
    self.NVYimage.layer.borderWidth = 1.00;
    [NVView addSubview:_NVYimage];
    [self.NVYimage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(NVView).offset(18.00*AUTO_WIDTH/2);
        make.left.equalTo(NVView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(8.00*AUTO_WIDTH, 8.00*AUTO_WIDTH));
        
    }];
    
    //女
     _NVLabel1= [[UILabel alloc]init];
    _NVLabel1.text = @"女";
    _NVLabel1.textColor = HS;
    _NVLabel1.alpha=0.7;
    _NVLabel1.font = [UIFont systemFontOfSize:TEXTLABELFONT*TEXTWEIGHT];
    _NVLabel1.textAlignment = NSTextAlignmentCenter;
    [NVView addSubview:_NVLabel1];
    [_NVLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(NVView).offset(7.00*AUTO_WIDTH/2);
        make.right.equalTo(NVView.mas_right).offset(-5.00*AUTO_WIDTH);
        make.left.equalTo(self.NVYimage.mas_right);
        
    }];
    
    _NYimage.userInteractionEnabled = YES;
    _NVLabel.userInteractionEnabled = YES;
    _NVYimage.userInteractionEnabled = YES;
    _NVLabel1.userInteractionEnabled = YES;
    
    UITapGestureRecognizer *tapMen = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menAction:)];
    [self.NVYimage addGestureRecognizer:tapMen];
    [_NVLabel1 addGestureRecognizer:tapMen];
}

- (void)setImage:(UIImage *)image {
    _image = image;
    if (!_image) {
    
        self.headImageV.image = [UIImage imageNamed:@"touxiang"];
    } else {
        self.headImageV.image = _image;
    }
}

- (void)menAction:(UITapGestureRecognizer *)tap {

        self.NVYimage.layer.borderColor=[[UIColor colorWithRed:229/255.0 green:22/255.0 blue:136/255.0 alpha:1]CGColor];
        self.NVYimage.backgroundColor=[UIColor colorWithRed:229/255.0 green:22/255.0 blue:136/255.0 alpha:1];
        self.NYimage.layer.borderColor=[[UIColor grayColor]CGColor];
        self.NYimage.backgroundColor=[UIColor whiteColor];
        self.NVLabel1.textColor=[UIColor colorWithRed:229/255.0 green:22/255.0 blue:136/255.0 alpha:1];
        self.NVLabel.textColor=HS;
        self.isMen = YES;

}

- (void)womenAction:(UITapGestureRecognizer *)tap {
    

    self.NYimage.layer.borderColor=[[UIColor colorWithRed:10/255.0 green:162/255.0 blue:233/255.0 alpha:1]CGColor];
    self.NYimage.backgroundColor=[UIColor colorWithRed:10/255.0 green:162/255.0 blue:233/255.0 alpha:1];
    self.NVYimage.layer.borderColor=[[UIColor grayColor]CGColor];
    self.NVYimage.backgroundColor=[UIColor whiteColor];
    self.NVLabel.textColor=[UIColor colorWithRed:10/255.0 green:162/255.0 blue:233/255.0 alpha:1];
    self.NVLabel1.textColor=HS;
    self.isMen = NO;
 
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end


